# Contributor: David Huffman <storedbox@outlook.com>
# Maintainer: David Huffman <storedbox@outlook.com>

_gosu_repo='github.com/tianon/gosu'
_gosu_ver=1.14
_gosu_src="gosu-$_gosu_ver"

_runc_repo='github.com/opencontainers/runc'
_runc_ver=1.1.0
_runc_src="runc-$_runc_ver"

pkgname=gosu
pkgver=$_gosu_ver
pkgrel=3
pkgdesc="Simple Go-based setuid+setgid+setgroups+exec"
url="https://github.com/tianon/gosu"
arch="all"
license="Apache-2.0"
makedepends="coreutils go"
source="https://github.com/tianon/gosu/archive/$_gosu_ver/$_gosu_src.tar.gz
	https://github.com/opencontainers/runc/archive/v$_runc_ver/$_runc_src.tar.gz"
options="!check" # require docker to run tests

builddir="$srcdir"/$_gosu_repo
prepare() {
	mkdir -p $_gosu_repo $_runc_repo
	mv -T $_gosu_src $_gosu_repo
	mv -T $_runc_src $_runc_repo

	default_prepare
}

build() {
	CGO_ENABLED=0 \
		GOPATH="$startdir:$srcdir/$_runc_repo/Godeps/_workspace" \
		GO111MODULE=off \
		go build -v -ldflags '-s -w'
}

package() {
	local bindir="$pkgdir/usr/bin"
	mkdir -p "$bindir"
	cp gosu "$bindir"
}

sha512sums="
258bc33bf7150f4520e8b5cd0497ccfe3ee83d39c866565ec5e0cfe3ccd28ef1a5694075b301936c94a45cd44621c44e28c3e0fcd0acd465a3a4fe5cff85adf2  gosu-1.14.tar.gz
542ea87c488fd120f2b77e53e2c197f09cd504fbe55dbe47008aaa5b0565aa300fc49f8cadc24ead796e45a4e95a30dfb08bfeefa58dc370145a218fd2869e41  runc-1.1.0.tar.gz
"
